<?php

use yii\db\Migration;
use yii\db\Schema;

/**
 * Class m180327_095424_ADD_FIELD_CUSTOMER
 */
class m180327_095424_ADD_FIELD_CUSTOMER extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {   
         $this->addColumn('{{customer}}', 'color', Schema::TYPE_STRING. "(64) NULL COMMENT '衣服颜色' ");
         $this->addColumn('{{customer}}', 'passport_check', Schema::TYPE_INTEGER. "(1) DEFAULT  '1' COMMENT '护照审核 1 未审核 2 审核通过' ");
         $this->addColumn('{{customer}}', 'cancel', Schema::TYPE_INTEGER. "(1) DEFAULT  '1' COMMENT '人员是否取消旅行 1.未取消 2.待审核 3.已取消' ");

         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        //客人审核信息
        $this->createTable('customer_check', [
            "id" =>           Schema::TYPE_PK,
            "first_name" =>   Schema::TYPE_STRING.    "(32) NULL COMMENT '姓'",
            "last_name" =>    Schema::TYPE_STRING.    "(32) NULL COMMENT '名'",
            "en_first_name"=> Schema::TYPE_STRING.    "(32) NULL COMMENT '英文姓'",
            "en_last_name"=>  Schema::TYPE_STRING.    "(32) NULL COMMENT '英文名'",
            "pinyin"=>        Schema::TYPE_STRING.    "(255) NULL COMMENT '名字拼音'",
            "gender" =>       Schema::TYPE_INTEGER.   "(1) DEFAULT  '0' COMMENT '1 男 2 女'",
            "birthday" =>     Schema::TYPE_DATE.      " NULL COMMENT '出生日期'",
            "country"=>       Schema::TYPE_STRING.    "(64) NULL COMMENT '国籍'",
            "passport"=>      Schema::TYPE_STRING.    "(255) NULL COMMENT '护照号码'",
            "passport_add"=>  Schema::TYPE_STRING.    "(255) NULL COMMENT '护照签发地'",
            "passport_date"=> Schema::TYPE_DATE.      " NULL COMMENT '护照有效期'",
            "passport_grant" => Schema::TYPE_DATE.    " NULL COMMENT '护照签发日期'",
            "passport_img" => Schema::TYPE_STRING.    "(255) null COMMENT '护照图片'", 
            "native"=>        Schema::TYPE_STRING.    "(64) null COMMENT '出生地'",
            "phone"=>         Schema::TYPE_STRING.    "(64) NULL COMMENT '手机号'",
            "remark"=>        Schema::TYPE_STRING.    "(255) NULL COMMENT '备注说明'",
            "name"=>          Schema::TYPE_STRING.    "(64) NULL COMMENT '姓名'",
            "passport_check" => Schema::TYPE_INTEGER. "(1) DEFAULT  '1' COMMENT '护照审核 1 未审核 2 审核通过'",
            "user_id" =>      Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>   Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>   Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

        //
        $this->createIndex('customer_check','customer_check',['passport'],true);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m180327_095424_ADD_FIELD_CUSTOMER cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180327_095424_ADD_FIELD_CUSTOMER cannot be reverted.\n";

        return false;
    }
    */
}
